package com.hjt.frame.event;

import org.opencv.core.Point;
import com.hjt.adb.utils.DeviceUtil;
import com.hjt.dto.MemberInfo;
import com.hjt.frame.MainFrame;

public class SyncClickActionEvent {

	public static void syncClick(int x, int y, int w, int h) {
		new Thread(() -> {
			for(MemberInfo m: MainFrame.members) {
				if(m.getSyncMember()) {
					double mX = m.getWidth()  * x * 1.0 / w ;
					double mY = m.getHeight()  * y * 1.0 / h ;
					Point p = new Point();
					p.x = mX + Math.random() * 10;
					p.y = mY + Math.random() * 10;
					DeviceUtil.click(m.getDevice(), p);
					try {
						Thread.sleep(Double.valueOf(300 + Math.random() * 100).longValue());
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}
		}).start();
	}
}
